<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers                           |
// |                                                                      |
// | http://www.zen-cart.com/index.php                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | license@zen-cart.com so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
//
// ===============================================================================
// Add-On: Envios List v1.0
// Designed for: Zen Cart 1.3.x series
// Created by: Fredie Auditor (http://www.sharedterminl.info)
//
// Donations:  Please support Zen Cart!  paypal@zen-cart.com  - Thank you!
// ===============================================================================

if (isset($_POST['selReport'])) {  
  require('includes/templates/tpl_envios_products.php');
} else { // Select status

require('includes/application_top.php');
global $db;
$sql = "SELECT orders_id FROM ".TABLE_ORDERS." WHERE orders_status = '2'";
$orders_facturars = $db->Execute($sql);

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title>Generate Envios Report</title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script type="text/javascript">
  <!--
  function init()
  {
    cssjsmenu('navbar');
    if (document.getElementById)
    {
      var kill = document.getElementById('hoverJS');
      kill.disabled = true;
    }
  }
  // -->
</script>
</head>
<body onLoad="init()">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
<!-- body_text //-->

    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading">Envios List</td>
            <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td>
        <p>
        This will generate envios either .txt or .csv file, please select file type and click Generate button.
        </p>          
          <form style="margin-left: 20px;" action="envios_products.php" method="post">
          <table width="30%">
          <tr>
          <td valign="top">Generate Report :</td>
          <td valign="top">
<?php
            if(!$orders_facturars->EOF)
{
?>
        <select multiple="multiple" name="orders_id[]" style="height: 80px">             
            <?php                        
            echo '<option value="0">Select all</option>';
            while (!$orders_facturars->EOF) {
                $oid = $orders_facturars->fields["orders_id"];   
                echo '<option value="'.$oid.'">'.$oid.'</option>';                
                $orders_facturars->MoveNext();
            }
            ?>            
        </select>    
<?php
}
?>
          </td>
          <td valign="top">
          <select id="selReport" name="selReport">
           <option value="0">--Please select--</option>
           <option value="txt">CTT Expresso</option>
           <option value="txtes">CTT Expresso Espanha</option>
           <option value="txtcsv">NACEX</option>
           <option value="txtseur">SEUR</option>
          </select>
          </td>
          <td valign="top"><input type="submit" id="btnGenerate" onclick="return validate();" value="Generate"></td>
          </tr>
          </table>
          
          </form>
        </td>
      </tr>
    </table></td>

<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->
<script type="text/javascript">
function validate()
{
    var repType = document.getElementById('selReport');
    if(repType.value=='0')
     {
         alert('Please select file type to generate envios');
         repType.focus();
         return false;         
     }
     return true;
}
</script>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php

require(DIR_WS_INCLUDES . 'application_bottom.php');

} // Select status
?>